Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

159
Visualizações
"!=" and "is blank" not working as expected

Can you please help me correct me app script code?

function sendEmails() {

  var ss = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet();
  var lr = ss.getLastRow ();
  

  for (var i=2;i<=lr;i++)
  {

    var currentemail =ss.getRange (i,1).getValue();
    var currentclasstitle =ss.getRange (i,3).getValue();
    var currentcondition =ss.getRange (i,4).getValue();
    var Confirmation =ss.getRange (i,4).setValue("Email Sent");

    if (currentcondition!="Email Sent"&& currentemail !=""){

    MailApp.sendEmail(currentemail,currentclasstitle+ " Invoice Request Updates ","Hi");}
    else if (currentemail!="") {Confirmation}
  }
  
}

everything not showing correctly after else if statement

what I want is

**

  • IF A3 is BLANK I WANT D3 also to be BLANK

**

as per my above code, even if A3 is blank D3 populates email sent

Google SS screenshot

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

That's because you're setting value in D3 before your If statement

Replace this:-

    var Confirmation =ss.getRange (i,4).setValue("Email Sent");

    if (currentcondition!="Email Sent"&& currentemail !=""){

    MailApp.sendEmail(currentemail,currentclasstitle+ " Invoice Request Updates ","Hi");}
    else if (currentemail!="") {Confirmation}

with this:-

    const confirmation = ss.getRange (i,4)
    if (currentemail !== "" && currentcondition !== "Email Sent" )
    {      
      MailApp.sendEmail(currentemail,currentclasstitle+ " Invoice Request Updates ","Hi");
      confirmation.setValue("Email Sent");
    }

Reference:

if..else

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda